package com.yanqu.road.server.cmd.tradewar;

import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.cross.tradewar.CrossTradeWarProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_TRADE_WAR_QUERY_CAN_WANTED, desc = "跨服商战查询能否通缉")
public class CrossTradeWarQueryCanWantedCmd extends CrossUnionCommand {
    private int activityId;
    private long wantedUserId;
    private long wantedServerId;
    private long userId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarQueryWantedReqMsg reqMsg = CrossTradeWarProto.CrossTradeWarQueryWantedReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        wantedUserId = reqMsg.getWantedUserId();
        wantedServerId = reqMsg.getWantedServerId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossTradeWarProto.CrossTradeWarToServerQueryWantedReqMsg.Builder msg = CrossTradeWarProto.CrossTradeWarToServerQueryWantedReqMsg.newBuilder();
        msg.setActivityId(activityId);
        msg.setWantedUserId(wantedUserId);
        msg.setQueryUserId(userId);
        msg.setQueryServerId(serverId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.S_CROSS_TRADE_WAR_TO_SERVER_QUERY_CAN_WANTED, msg);
        MessageHelper.sendPacket(wantedServerId, wantedUserId, pbMsg);
    }

    @Override
    public void sendData() {

    }
}
